package com.ngmaster.apiserver.controller;

import com.ngmaster.apiserver.common.BaseBody;
import com.ngmaster.apiserver.services.ILocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * 获取地理位置
 */
@RestController
@ResponseBody
@CrossOrigin
public class LocationController {

	/**
	 * 缓存服务
	 */
	@Autowired
	private ILocationService locationService;
	
	/**
	 * 根据经纬度获得城市
	 * @param location 经纬度使用 英文逗号隔开
	 * @return
	 */
	@RequestMapping(value = "location/getCity", method = { RequestMethod.GET })
	public BaseBody getCityByLongitudeAndLatitude(String location) throws IOException {
		return locationService.getCityByLongitudeAndLatitude(location);
	}
}
